/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sisfo.astacala.model;

import java.util.List;
import org.hibernate.Session;
import sisfo.astacala.util.UtilHibernate;

/**
 *
 * @author arif
 */
public class ModelDivision implements ModelInterface {

    private static ModelDivision modelDivision;

    public static ModelDivision getInstance() {
        if (modelDivision == null) {
            modelDivision = new ModelDivision();
        }
        return modelDivision;
    }

    @Override
    public boolean insertModel(Object object) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public String updateModel(Object object) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public String deleteModel(Object object) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public Object searchModel(Object object) {
        List divisions;
        try {
            Session session = UtilHibernate.getSessionFactory().openSession();
            session.beginTransaction();
            divisions = session.createQuery(object.toString()).list();
            session.getTransaction().commit();
            session.close();
        } catch (Exception exception) {
            divisions = null;
        }
        return divisions;
    }

    @Override
    public Object getAllModel(Object object) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
